#pragma once
#include"SceneBase.h"
#include"Myvec.h"
#include"../jsonCpp/json.h"
#include<queue>

class GameMonster;

class GameScene:public SceneBase
{
public:
	GameScene(Object* master, int sceneId);
	virtual ~GameScene();

	virtual void addActor(const int& id, const int64_t& sock, const Myvec& pos, const Myvec& forward,const std::string& name);

 	virtual void removeActor(const int& id);

    virtual	void updateActorTransform(const int& id, const Myvec& pos, const Myvec& forward, const Myvec& veloci);;

	virtual void updateActorPosAndFor(const int& id, const Myvec& pos,const Myvec& foprward);

	virtual std::vector<GamePlay*> getGamePlayNearPlayers(const int& id);

	virtual void monsterFight(const int& monsterId, const int& figtId);

	virtual void monsterFightResult(const int& userId, const int& monsterId, const int& success);
	
	virtual void update(float dt);
private:
	void updateGamePlayPos(GamePlay* play, const Myvec& pos, bool isAdd = false);

	std::string getSceneKey(const int& i, const int& j);

	void getPlayUpdateVelocity(GamePlay* play,Json::Value* smessage);

	void notifyPlay(GamePlay* play, bool isAdd);

	void notifyPlayLeaveView(GamePlay* play, GamePlay* otherPlay);
	
	virtual void notifyMonster(GamePlay* play);

	void removeMonsterUserId(const int& userId);

	void initMonsters();

	void checkMonsterDie(float dt);

	void notifyMobnsterReborn(GameMonster& monster);

	std::map<std::string, std::list<GamePlay*>> m_playPosMap;
	std::map<int, GameMonster> m_monsterMaps;
	std::queue<int> m_dieMonsterQueue;
	float m_dieCd = 10;
	float m_totalDt = 0;
};

